$(document).ready(function() {
	//从cookie中获得用户标识
	var param = $.cookie("worktid");
	var worktid = JSON.parse(param);
	var name = worktid.name;
	var Wtid = worktid.worktid;
	var url = jurisdictionport + "/AuthorityController/getSingleMenu";
	//发送get请求数据
	var getData = (function() {
		$.get(url, {
			username: name,
			parentid: '0'
		}, function(result) {
			var code = result.code;
			if(code == 0) {
				console.log(name, Wtid);
				console.log(result);
				$.each(result.object, function(idx, obj) {
					var idx = idx + 1;
					var html = '<li id="' + obj.resourceid + '">\
											<div class="nav-list">\
												<img src="../../resources/images/'+obj.imageaddr+'.png" />\
												<p>' + obj.name + '</p>\
											</div>\
										</li>';
					$(".nav-left ul").append(html);
					$(".username").text(name);
					getNav();
				}, 'JSON');
			} else {
				alert("您的登录认证已失效，请重新登录！");
			}
		}, )

	});
	getData();

	//cookie存值
	var getNav = (function() {
		$(".nav-left ul li").click(function() {
			var id = $(this).attr('id');
			var values = {};
			values.id = id;
			values.userName = name;
			values.w = Wtid;
			$.cookie("nav", JSON.stringify(values),{ expires: 7, path: '/' });
			if(id == "location"){
				location.href = 'localtion.html';
			}else{
				location.href = 'indexForm.html';
			}
		})
	});

});